package com.itheima.springbootinit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
public class HelloController {

    @Value("${name}")
    private String name;

    @Value("${person.name}")
    private String name2;

    @Value("${person.age}")
    private int age;

    @Value("${address[0]}")
    private String address1;

    @Value("${msg1}")
    private String msg1;

    @Value("${msg2}")
    private String msg2;

    @Autowired
    private Environment env;


    @RequestMapping("/hello4")
    public String hello4() {
        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("person.age"));

        return "hello SpringBoot2";
    }


    @RequestMapping("/hello3")
    public String hello3() {

        System.out.println(name);
        System.out.println(name2);
        System.out.println(age);
        System.out.println(address1);
        System.out.println(msg1);
        System.out.println(msg2);

        return "hello SpringBoot3";
    }

    @RequestMapping("/hello")
    public String hello() {
        return "hello SpringBoot2";
    }
}
